implemented as variables on all systems.
Signed-off-by: Keir Fraser <keir@xensource.com>
#include <signal.h>
#include "utils.h"
-void xprintf(const char *fmt, ...)
+static void default_xprintf(const char *fmt, ...)
{
va_list args;
- if (!stderr)
- return; /* could trace()? */
-
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fflush(stderr);
}
+void (*xprintf)(const char *fmt, ...) = default_xprintf;
+
void barf(const char *fmt, ...)
{
char *str;
void barf(const char *fmt, ...) __attribute__((noreturn));
void barf_perror(const char *fmt, ...) __attribute__((noreturn));
-void xprintf(const char *fmt, ...);
+void (*xprintf)(const char *fmt, ...);
#define eprintf(_fmt, _args...) xprintf("[ERR] %s" _fmt, __FUNCTION__, ##_args)
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
-
- /* Get ourselves a nice xenstored crash if these are used. */
- stdin = NULL;
- stdout = NULL;
- stderr = NULL;
+ xprintf = trace; /* xprintf() must not use stderr */
}
signal(SIGHUP, trigger_reopen_log);